//////////////////////////////////////////////////////////////////////////
//
// This file is a part of UKROP project.
// Copyright (c) Vladimir Gumenuk
//
// PROJECT:         Xort Custom Debug Engine
// FILE:            Process.h : Declaration of the CProcess
// AUTHOR:          Vladimir Gumenuk
// DATE:            Dec-2012 -- Jan-2013
// MODIFICATIONS:
//
//////////////////////////////////////////////////////////////////////////

#pragma once
#include "resource.h"       // main symbols
#include "XortDebugEngine_i.h"

extern const GUID __declspec(selectany) IID_XortVirtualProcess = 
{ 0x8523A7C8, 0x4B80, 0x11E2, { 0x8E, 0x32, 0xA4, 0x2A, 0x62, 0x88, 0x70, 0x9B } };

//////////////////////////////////////////////////////////////////////////
// CProcess
class ATL_NO_VTABLE CProcess :
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CProcess, &CLSID_Process>,
	public IDebugProcess2,
    public IXProcess
{
public:
	CProcess();
    virtual ~CProcess();

DECLARE_REGISTRY_RESOURCEID(IDR_PROCESS)

BEGIN_COM_MAP(CProcess)
	COM_INTERFACE_ENTRY(IDebugProcess2)
    COM_INTERFACE_ENTRY(IXProcess)
END_COM_MAP()

DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct();
	void FinalRelease();

    IMPLEMENT_CREATE(CProcess, IDebugProcess2);

public:
    //////////////////////////////////////////////////////////// 
    //IDebugProcess2 
    STDMETHOD(GetInfo)( PROCESS_INFO_FIELDS Fields, __RPC__out PROCESS_INFO *pProcessInfo );
    STDMETHOD(EnumPrograms)( __RPC__deref_out_opt IEnumDebugPrograms2 **ppEnum );
    STDMETHOD(GetName)( GETNAME_TYPE gnType, __RPC__deref_out_opt BSTR *pbstrName );
    STDMETHOD(GetServer)( __RPC__deref_out_opt IDebugCoreServer2 **ppServer );
    STDMETHOD(Terminate)();
    STDMETHOD(Attach)( __RPC__in_opt IDebugEventCallback2 *pCallback, GUID *rgguidSpecificEngines, DWORD celtSpecificEngines, HRESULT *rghrEngineAttach );
    STDMETHOD(CanDetach)();
    STDMETHOD(Detach)();
    STDMETHOD(GetPhysicalProcessId)( __RPC__out AD_PROCESS_ID *pProcessId );
    STDMETHOD(GetProcessId)( __RPC__out GUID *pguidProcessId );
    STDMETHOD(GetAttachedSessionName)( __RPC__deref_out_opt BSTR *pbstrSessionName );
    STDMETHOD(EnumThreads)( __RPC__deref_out_opt IEnumDebugThreads2 **ppEnum );
    STDMETHOD(CauseBreak)();
    STDMETHOD(GetPort)( __RPC__deref_out_opt IDebugPort2 **ppPort );

    STDMETHOD(LaunchExecutable)( LPCOLESTR lpszExeFilePath );

private:
    PROCESS_INFORMATION         m_pi;
};

OBJECT_ENTRY_AUTO(__uuidof(Process), CProcess)
